package com.kesh.ltank.game;

import java.util.Arrays;
import java.util.List;

import android.graphics.Point;

import com.android.framework.Audio;
import com.android.framework.Graphics;
import com.android.framework.Graphics.ImageFormat;
import com.android.framework.Image;
import com.android.framework.Music;
import com.android.framework.Sound;

public class GlobalVars {
	
	private static final String leveldatapath = "leveldata";
	public static final String lvlFileName = leveldatapath + "/LaserTank.lvl";
	public static final int startLevel = 0;
	public static int currentLevel = 0;
	public static byte[] lvlData;
	
	public static enum Difficulty {
			Novice(0), 
			Easy(20), 
			Medium(40), 
			Hard(80), 
			Deadly(160);
		
		public final int dcltyValue;
		
		Difficulty(int inDcltyValue){
			this.dcltyValue = inDcltyValue;
		}
	};
	
	
	public static final Point lvlFieldLen = new Point(16,16);
	public static final Point playFieldStart = new Point(0,170);
	public static final Point playFieldLen = new Point(480,480);
	public static final Point playImageOrigLen = new Point(40,40);
	public static Point playImageScaledLen = new Point(40,40);

	private static final String musicpath = "music";
	private static final String soundpath = "sounds";
	private static final String screenimagespath = "screenimages";
	private static final String gameimagespath = "gameimages";
	private static final String playimagespath = "playimages";

	public static final float musicVolume = 0.85f;
	public static final float soundVolume = 0.85f;

	public static enum GameMusic {
			Theme1("Theme1.mp3");		
		public final String filename;
		public Music music;

		GameMusic(String inFileName) {
			this.filename = musicpath + "/" + inFileName;
			this.music = null;
		}

		public void loadMusic(Audio gameAudio) {
			this.music = gameAudio.createMusic(this.filename);
			this.music.setLooping(true);
			this.music.setVolume(GlobalVars.musicVolume);
		}

		public void play() {
			this.music.play();
		}

		public void pause() {
			this.music.pause();
		}
	}

	public static enum GameSounds {
		ShootSound("Shoot.mp3"),
		BlastSound("Blast.mp3"),
		MoveSound("Move.mp3");
		
		public final String filename;
		public Sound sound;

		GameSounds(String inFileName) {
			this.filename = soundpath + "/" + inFileName;
			this.sound = null;
		}

		public void loadSound(Audio gameAudio) {
			this.sound = gameAudio.createSound(this.filename);
		}

		public void play() {
			this.sound.play(soundVolume);
		}
	}
	
	public static enum ScreenImages {
		Splash("Splash.png"),
		Menu("Menu.png"),
		Bacground("Background.png");
		
		public final String filename;
		public Image image;

		ScreenImages(String inFileName) {
			this.filename = screenimagespath + "/" + inFileName;
			this.image = null;
		}

		public void loadImage(Graphics g) {
			this.image = g.newImage(this.filename, ImageFormat.RGB565);
		}
	}
	
	public static enum GameImages {
			FireButton("FireButton.png"),
			FireButton_Pressed("FireButton_Pressed.png"),
			UnDo("UnDo.png"),
			UnDo_Pressed("UnDo_Pressed.png"),
			ReDo("ReDo.png"),
			ReDo_Pressed("ReDo_Pressed.png"),
			Bubble("Bubble.png"),
			Bubble_Pressed("Bubble_Pressed.png");
			
		public final String filename;
		public Image image;

		GameImages(String inFileName) {
			this.filename = gameimagespath + "/" + inFileName;
			this.image = null;
		}

		public void loadImage(Graphics g) {
			this.image = g.newImage(this.filename, ImageFormat.RGB565);
		}
	}
	
	public static enum PlayImages {
			Ground("Ground.png",0),
			LTank_U("Tank_Up.png",1),
			Flag("Flag.png",2),
			Water("Water.png",3),
			Steel("SteelBlock.png",4),
			MBlock("MovableBlock.png",5),
			Brick("Brick.png",6),
			ATank_U("AntiTank_Up.png",7),
			ATank_R("AntiTank_Right.png",8),
			ATank_D("AntiTank_Down.png",9),
			ATank_L("AntiTank_Left.png",10),
			MMirror_U("MovableMirror_Up.png",11),
			MMirror_R("MovableMirror_Right.png",12),
			MMirror_D("MovableMirror_Down.png",13),
			MMirror_L("MovableMirror_Left.png",14),
			Stream_U("Stream_Up.png",15),
			Stream_R("Stream_Right.png",16),
			Stream_D("Stream_Down.png",17),
			Stream_L("Stream_Left.png",18),
			Crystal("CrystalBlock.png",19),
			RMirror_U("RotaryMirror_Up.png",20),
			RMirror_R("RotaryMirror_Right.png",21),
			RMirror_D("RotaryMirror_Down.png",22),
			RMirror_L("RotaryMirror_Left.png",23),
			Ice("Ice.png",24),
			ThinIce("ThinIce.png",25),
			Bridge("Bridge.png",26),
			Tunnel_0("Tunnel_0.png",64),
			Tunnel_1("Tunnel_1.png",66),
			Tunnel_2("Tunnel_2.png",68),
			Tunnel_3("Tunnel_3.png",70),
			Tunnel_4("Tunnel_4.png",72),
			Tunnel_5("Tunnel_5.png",74),
			Tunnel_6("Tunnel_6.png",76),
			Tunnel_7("Tunnel_7.png",78),
			LTank_R("Tank_Right.png",82),
			LTank_D("Tank_Down.png",83),
			LTank_L("Tank_Left.png",84),
			DTank_U("DTank_Up.png",85),
			DTank_R("DTank_Right.png",86),
			DTank_D("DTank_Down.png",87),
			DTank_L("DTank_Left.png",88);

		public final String filename;
		public final int id;
		public Image image;

		PlayImages(String inObjFileName, int inObjId) {
			this.filename = playimagespath + "/" + inObjFileName;
			this.id = inObjId;
			this.image = null;
		}

		public void loadImage(Graphics g) {
			this.image = g.newImage(this.filename, ImageFormat.RGB565);
		}
	}

	public static enum PlayObjects {
			Ground(0),
			LTank_U(1),
			Flag(2),
			Water(3),
			Steel(4),
			MBlock(5),
			Brick(6),
			ATank_U(7),
			ATank_R(8),
			ATank_D(9),
			ATank_L(10),
			MMirror_U(11),
			MMirror_R(12),
			MMirror_D(13),
			MMirror_L(14),
			Stream_U(15),
			Stream_R(16),
			Stream_D(17),
			Stream_L(18),
			Crystal(19),
			RMirror_U(20),
			RMirror_R(21),
			RMirror_D(22),
			RMirror_L(23),
			Ice(24),
			ThinIce(25),
			Bridge(26),
			Tunnel_0(64),
			Tunnel_1(66),
			Tunnel_2(68),
			Tunnel_3(70),
			Tunnel_4(72),
			Tunnel_5(74),
			Tunnel_6(76),
			Tunnel_7(78),
			LTank_R(82),
			LTank_D(83),
			LTank_L(84),
			DTank_U(85),
			DTank_R(86),
			DTank_D(87),
			DTank_L(88),
			OutOfBounds(100);
	
		public final int id;
	
		PlayObjects(int inObjId) {
			this.id = inObjId;
		}
	}
	
	public static enum Direction {
		Up, Right, Down, Left
	};

	public static enum GameState {
		Ready, Running, Paused, Dead, Drowned, Won
	}

	public static enum BulletState {
		Fired, InMotion, MoveTank, HitTank, HitBrick,HitDTank, PassCrystal, MoveBlock, HitRMirror, EnterRMirror, ExitRMirror, MoveMirror, EnterMMirror, ExitMMirror, HitSteel, BlockExitsTunnel, Exploded
	}
	
	public static enum TankState {
		OnStream, OnIce, OnWater, OnThinIce, OnTunnel, Firing, Moving, ShotDead, MissFire, CurATankFired, PrevATankFired, Blocked, BothATankFired, ReachedFlag
	}
	
	public static enum AntiTankState {
		MissFire, Fired, Firing, Exploded, HitTank
	}

	public static enum FirePathState {
		ATankFound, Clear, Blocked
	}
	
	
	public static List<PlayObjects> fixedObjects = Arrays
			.asList(PlayObjects.Steel, PlayObjects.MBlock, PlayObjects.Brick,
					PlayObjects.DTank_U, PlayObjects.DTank_R,
					PlayObjects.DTank_D, PlayObjects.DTank_L,
					PlayObjects.ATank_U, PlayObjects.ATank_R,
					PlayObjects.ATank_D, PlayObjects.ATank_L,
					PlayObjects.MMirror_U, PlayObjects.MMirror_R,
					PlayObjects.MMirror_D, PlayObjects.MMirror_L,
					PlayObjects.Crystal, PlayObjects.RMirror_U,
					PlayObjects.RMirror_R, PlayObjects.RMirror_D,
					PlayObjects.RMirror_L);

	public static List<PlayObjects> streamObjects = Arrays.asList(PlayObjects.Stream_U,PlayObjects.Stream_R,PlayObjects.Stream_D,PlayObjects.Stream_L);
	public static List<PlayObjects> tunnelObjects = Arrays.asList(PlayObjects.Tunnel_0,PlayObjects.Tunnel_1,PlayObjects.Tunnel_2,PlayObjects.Tunnel_3,PlayObjects.Tunnel_4,PlayObjects.Tunnel_5,PlayObjects.Tunnel_6,PlayObjects.Tunnel_7);

}
